import java.util.Enumeration;
import java.util.Hashtable;


public class ItemTable implements ITable
{
	Hashtable<Integer,IFinancial_Item> itemTable = null;
	
	public ItemTable()
	{
		itemTable = new Hashtable<Integer,IFinancial_Item>();
	}
	
	public void addItem(IFinancial_Item item)
	{
		if(checkDuplicate(item) == false)
		{
			int key = itemTable.size() + 1;
			itemTable.put(new Integer(key), item);
		}
		
		else
			System.out.println("Duplicate entry exists. Item not added !!");
	}
	
	public IFinancial_Item getItem(int key)
	{
		return itemTable.get(new Integer(key));
	}
	
	public int getRecordCount()
	{
		return itemTable.size();
	}
	
	private boolean checkDuplicate(IFinancial_Item item)
	{
		if(itemTable.containsValue(item))
			return true;
		
		return false;
	}
	
	public Enumeration<IFinancial_Item> getEnumerator()
	{
		return itemTable.elements();
	}
}
